module.exports = function (app) {
  const {
    Bone,
    DataTypes: { STRING, BOOLEAN, DATE, JSON, BIGINT },
  } = app.model;
  class Role extends Bone {
    static table = 'role';
    static attributes = {
      id: {
        type: BIGINT,
        primaryKey: true,
      },
      name: {
        type: STRING,
        validate: {
          notEmpty: true,
          notNull: true,
        },
      },
      // 角色编码
      code: {
        type: STRING,
        validate: {
          notEmpty: true,
          notNull: true,
        },
      },
      // 权限菜单 { data: STRING[]}
      menuIds: {
        type: JSON,
        // defaultValue: {}
      },
      // 组件权限 { data: STRING[]}
      perms: {
        type: JSON,
      },
      // 数据权限(0-所有数据；1-部门及子部门数据；2-本部门数据；3-本人数据) 
      dataScope: {
        type: BIGINT,
        validate: {
          notEmpty: true,
          notNull: true,
        },
        defaultValue: 1,
      },
      // 角色状态(1-正常；0-停用)
      status: {
        type: BIGINT,
        defaultValue: 1
      },
      // 排序
      sort: {
        type: BIGINT,
        defaultValue: 2,
      },
      createdAt: {
        type: DATE,
      },
      updatedAt: {
        type: DATE,
      },
      deleteAt: {
        type: DATE,
      },
    };
  }
  return Role;
};
